﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Filter;
using Newtonsoft.Json.Linq;
using HttpUtility;
using WechatModel;

namespace WechatDAL
{
    public class W_MenuDal
    {
        /// <summary>
        /// 为公众号创建自定义菜单
        /// </summary>
        /// <param name="m">实体对象</param>
        /// <returns></returns>
        public bool Insert(string menu)
        {
            JObject jo = Poster.Post(WechatAPI4Public.BuildMenu, menu);
            if (jo == null)
                return false;
            else
            {
                if (jo["errcode"].ToString() == "0" && jo["errmsg"].ToString() == "ok")
                    return true;
                else
                    return false;
            }
        }

        /// <summary>
        /// 删除公众号的自定义菜单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool Delete()
        {
            JObject jo = Poster.Get(WechatAPI4Public.DeleteMenu);
            if (jo == null)
                return false;
            else
            {
                if (jo["errcode"].ToString() == "0" && jo["errmsg"].ToString() == "ok")
                    return true;
                else
                    return false;
            }
        }
    }
}
